<?php
declare (strict_types=1);

namespace app\common\queue\payment;

use app\common\model\payment\PaymentOrderItem;

class FailQueuePay
{
    // 处理支付成功后 因队列造成的支付状态等问题
    public function run()
    {
        halt(app(PaymentOrderItem::class)->field('order_no,order_sub_no,user_id,product_id')->withJoin(['main', 'expenditure'])->where('main.status', 10)->buildSql());
        $data = app(PaymentOrderItem::class)->field('order_no,order_sub_no,user_id,product_id')->withJoin(['main', 'expenditure'])->where('main.status', 10)->select()->hidden(['main', 'expenditure']);
        halt($data->toArray());
        foreach ($data as $item) {
            app(Payment::class)->run($item->order_no);
        }
    }
}
